package com.gkzf.ai.module.crm.controller.app.collect;

import com.gkzf.ai.framework.common.pojo.CommonResult;
import com.gkzf.ai.module.crm.controller.app.collect.vo.CollectReqVo;
import com.gkzf.ai.module.crm.controller.app.product.vo.ProductDetailsRespVO;
import com.gkzf.ai.module.crm.service.creditreportsimple.app.CollectService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 收藏
 */
@Tag(name = "App后台 - 小程序收藏")
@RestController
@RequestMapping("/collect")
@Validated
public class CollectAppController {

    @Resource
    private CollectService collectService;

    /**
     * 添加、删除收藏
     * @param reqVo 收藏对象
     */
    @PostMapping("/update")
    @Operation(summary = "添加、删除收藏")
    public CommonResult<Boolean> addFavorite(@Valid @RequestBody CollectReqVo reqVo) {
        collectService.addFavorite(reqVo);
        return CommonResult.success(true);
    }

    /**
     * 获取收藏列表
     * @param reqVo 获取收藏列表对象
     * @return 收藏列表
     */
    @PostMapping("/getCollectList")
    @Operation(summary = "收藏列表")
    public CommonResult<List<ProductDetailsRespVO>> getCollectList(@Valid @RequestBody CollectReqVo reqVo) {
        List<ProductDetailsRespVO>  collect = collectService.getCollectList(reqVo);
        return CommonResult.success(collect);
    }

    /**
     * 获取收藏数
     * @param reqVo 获取收藏数对象
     * @return 收藏数
     */
    @PostMapping("/getCollectCount")
    @Operation(summary = "获取收藏数")
    public CommonResult<Long> getCollectCount(@Valid @RequestBody CollectReqVo reqVo) {
        return CommonResult.success(collectService.getCollectCount(reqVo));
    }
}
